package com.swgk.core.base.model.entity;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class ListResponse<T> implements Serializable {
    @SerializedName(value = "list", alternate = {"products", "records", "content", "record","dataList", "data", "result",   "biddingRegion"})
    private T list;
    @SerializedName(value = "pageNumber", alternate = {"current", "size", "curPage"})
    private int currentPage;
    @SerializedName(value = "pageSize", alternate = {"pages", "pageCount"})
    private int pageSize;
    @SerializedName(value = "totalRow", alternate = {"total", "totalElements", "recordCount", "totalPage"})
    private int total;
    @SerializedName("lastPage")
    private boolean lastPage;
    @SerializedName("firstPage")
    private boolean firstPage;
    //是否加载成功，默认成功
    private boolean isLoadSuccess = true;

    private List<VideoBean> videoProDict;

    public List<VideoBean> getVideoProDict() {
        return videoProDict;
    }

    public void setVideoProDict(List<VideoBean> videoProDict) {
        this.videoProDict = videoProDict;
    }

    public ListResponse() {
    }

    public ListResponse(boolean isLoadSuccess) {
        this.isLoadSuccess = isLoadSuccess;
    }

    public T getList() {
        if (list == null){
            return (T)new ArrayList();
        }
        return list;
    }

    public void setList(T list) {
        this.list = list;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public boolean isLastPage() {
        return lastPage;
    }

    public void setLastPage(boolean lastPage) {
        this.lastPage = lastPage;
    }

    public boolean isFirstPage() {
        return firstPage;
    }

    public void setFirstPage(boolean firstPage) {
        this.firstPage = firstPage;
    }

    public void setLoadSuccess(boolean loadSuccess) {
        isLoadSuccess = loadSuccess;
    }

    /**
     * 是否还有更多数据
     *
     * @return true：有更多数据 false：没有更多数据
     */
    public boolean haveMoreData() {
        return currentPage < pageSize;
    }

    /**
     * 是否加载成功
     *
     * @return true：加载成功 false：加载失败
     */
    public boolean isLoadSuccess() {
        return isLoadSuccess;
    }

    /**
     * 获取下一页页码
     *
     * @return 下一页页码
     */
    public int nextPage() {
        return currentPage + 1;
    }
}
